package Testdmo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Testdmo1.Date: 2024-02-23
 * Time：22:42
 */
public class J2_23 {
    // 汉诺塔游戏攻略

    /**
     * pos1 为起始地址
     * pos2 为中转位置
     * pos3 为终止位置
     */
    public static  void  move(char pos1,char pos2){
        System.out.print(pos1+"->"+pos2+" ");
    }

    public static  void  hano(int n,char pos1,char pos2,char pos3){
        if (n==1){
            move(pos1,pos3);
            return;
        }
        hano(n-1,pos1,pos3,pos2);

        move(pos1,pos3);

        hano(n-1,pos2,pos1,pos3);




    }


    public static void main(String[] args) {
        hano(1,'A','B','C');
        System.out.println();
        hano(2,'A','B','C');
        System.out.println();

        hano(3,'A','B','C');
        System.out.println();

        hano(4,'A','B','C');
        System.out.println();


    }
}
